package com.wlb365.doc.bean;

import lombok.Data;

import java.util.Collection;
import java.util.List;

/**
 * <p>
 * 概述：
 * </p>
 *
 * @author zwh
 * @version 1.0
 * @copyRight 北京微利宝信息技术有限公司  All right reserved.
 * @date 2020/3/21
 */
@Data
public class DocItem {
    private String module;
    private String name;
    private String version;
    private String summary;
    private String description;
    /**
     * 是否多文件上传
     */
    private boolean multiple;
    /**
     * http method列表
     */
    private Collection<String> httpMethodList;

    private Collection<String> produces;

    /** 模块顺序 */
    private int moduleOrder;

    /** 文档顺序 */
    private int apiOrder;

    /**
     * 请求参数
     */
    List<DocParameter> requestParameters;
    /**
     * 返回参数
     */
    List<DocParameter> responseParameters;

    public String getNameVersion() {
        return name + version;
    }

    /**
     * 是否是上传文件请求
     *
     * @return
     */
    public boolean isUploadRequest() {
        boolean upload = false;
        if (requestParameters != null) {
            for (DocParameter requestParameter : requestParameters) {
                String type = requestParameter.getType();
                if ("file".equalsIgnoreCase(type)) {
                    upload = true;
                    break;
                }
            }
        }
        return multiple || upload;
    }
}
